package com.kgc.scd.job;

import com.kgc.scd.bean.NotifySeckill;
import com.kgc.scd.bean.SeckillNotifyResult;
import com.kgc.scd.contant.SecKillMQConstant;
import com.kgc.scd.service.SecKillFeign;
import com.kgc.scd.service.SecKillService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.TimeUnit;


/**
 * @program: com.kgc.scd.job
 * @author: HarryXzy
 * @create: 2022-06-14 23:16
 * @description:
 **/
@Component
public class MyJob{

    @Autowired
    private SecKillService secKillService;
    @Autowired
    private SecKillFeign secKillFeign;

    private static Logger logger = LoggerFactory.getLogger(MyJob.class);



    @XxlJob("NotifySecKill")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB, Hello World.");
        // 获取所有要通知的活动及用户
        List<SeckillNotifyResult> getNowNeedNotify = secKillService.getNowNeedNotify();
        // 发送消息件去给用户发邮箱 改数据库状态
        secKillFeign.sendSeckillMsg(getNowNeedNotify);
        // default success
    }



}
